package ldk.util.radioview;

import android.content.Context;
import android.os.Build;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.annotation.StyleRes;
import android.util.AttributeSet;
import android.widget.FrameLayout;

/**
 *
 * Created by ldkxingzhe@163.com on 2017/4/26.
 */
public class RadioFrameLayout extends FrameLayout implements RadioViewHelper.RadioViewListener{

    private RadioViewHelper mRadioViewHelper;
    public RadioFrameLayout(@NonNull Context context) {
        this(context, null);
    }

    public RadioFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public RadioFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mRadioViewHelper = new RadioViewHelper(this, attrs);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public RadioFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        mRadioViewHelper = new RadioViewHelper(this, attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        mRadioViewHelper.onMeasure();
    }

    @Override
    public void setWidthHeightRadio(float radio) {
        mRadioViewHelper.setWidthHeightRadio(radio);
    }
}
